class IndexController < ApplicationController
  def index
    @topics = Topic.find(:all,
      :conditions=>"visible",
      :order=>"created_at desc",
      :limit=>5)
    @page = 1
  end

  def next_page
    @topics = Topic.find_on_page(params[:page].to_i, 5)
    @page = params[:page].to_i + 1
    respond_to do |format|
      format.js
    end
  end

  def last_page
    @topics = Topic.find_on_page(params[:page].to_i - 2, 5)
    @page = params[:page].to_i - 1
    respond_to do |format|
      format.js
    end
  end

end
